//cd removed in dofile
log using "log file additional robustness checks for dispersement 082124", replace
use "scedatapublicver.dta"

//examining interaction effects between dating history and skin color treatment
//and also interaction effects between sexual orientation and skin color treatment


local lvars1 F1L1 F1M1 F1D1 F3L1 F3M1 F3D1 F5L1 F5M1 F5D1 M3L1 M3M1 M3D1 ///
	M5L1 M5M1 M5D1 M6L1 M6M1 M6D1  ///
	F1L2 F1M2 F1D2 F3L2 F3M2 F3D2 F5L2 F5M2 F5D2 M3L2 M3M2 M3D2 ///
	M5L2 M5M2 M5D2 M6L2 M6M2 M6D2 ///  
	F1L3 F1M3 F1D3 F3L3 F3M3 F3D3 F5L3 F5M3 F5D3 M3L3 M3M3 M3D3 ///
	M5L3 M5M3 M5D3 M6L3 M6M3 M6D3   
foreach var of local lvars1 {
	gen `var'r = 6-`var'
	display in smcl as text "`var'"
	tab `var' `var'r, mi
}


expand 6
bysort case_id: gen n = _n
tab n, mi

forval i = 1/3 {
gen q`i' = 0
replace q`i' = F1L`i' if F1L`i' != . & n == 1
replace q`i' = F1M`i' if F1M`i' != . & n == 1
replace q`i' = F1D`i' if F1D`i' != . & n == 1
tab F1L`i' q`i' if n==1, mi
tab F1M`i' q`i' if n==1, mi
tab F1D`i' q`i' if n==1, mi

replace q`i' = F3L`i' if F3L`i' != . & n == 2
replace q`i' = F3M`i' if F3M`i' != . & n == 2
replace q`i' = F3D`i' if F3D`i' != . & n == 2
tab F3L`i' q`i' if n==2, mi
tab F3M`i' q`i' if n==2, mi
tab F3D`i' q`i' if n==2, mi

replace q`i' = F5L`i' if F5L`i' != . & n == 3
replace q`i' = F5M`i' if F5M`i' != . & n == 3
replace q`i' = F5D`i' if F5D`i' != . & n == 3
tab F5L`i' q`i' if n==3, mi
tab F5M`i' q`i' if n==3, mi
tab F5D`i' q`i' if n==3, mi

replace q`i' = M3L`i' if M3L`i' != . & n == 4
replace q`i' = M3M`i' if M3M`i' != . & n == 4
replace q`i' = M3D`i' if M3D`i' != . & n == 4
tab M3L`i' q`i' if n==4, mi
tab M3M`i' q`i' if n==4, mi
tab M3D`i' q`i' if n==4, mi

replace q`i' = M5L`i' if M5L`i' != . & n == 5
replace q`i' = M5M`i' if M5M`i' != . & n == 5
replace q`i' = M5D`i' if M5D`i' != . & n == 5
tab M5L`i' q`i' if n==5, mi
tab M5M`i' q`i' if n==5, mi
tab M5D`i' q`i' if n==5, mi

replace q`i' = M6L`i' if M6L`i' != . & n == 6
replace q`i' = M6M`i' if M6M`i' != . & n == 6
replace q`i' = M6D`i' if M6D`i' != . & n == 6
tab M6L`i' q`i' if n==6, mi
tab M6M`i' q`i' if n==6, mi
tab M6D`i' q`i' if n==6, mi

tab q`i', mi
replace q`i' = . if q`i' == 0
tab q`i', mi

}

gen light = 0
replace light = 1 if (F1L1 != . | F1L2 != . | F1L3 != .) & n == 1
replace light = 1 if (F3L1 != . | F3L2 != . | F3L3 != .) & n == 2
replace light = 1 if (F5L1 != . | F5L2 != . | F5L3 != .) & n == 3
replace light = 1 if (M3L1 != . | M3L2 != . | M3L3 != .) & n == 4
replace light = 1 if (M5L1 != . | M5L2 != . | M5L3 != .) & n == 5
replace light = 1 if (M6L1 != . | M6L2 != . | M6L3 != .) & n == 6

tab light, mi

gen med = 0
replace med = 1 if (F1M1 != . | F1M2 != . | F1M3 != .) & n == 1
replace med = 1 if (F3M1 != . | F3M2 != . | F3M3 != .) & n == 2
replace med = 1 if (F5M1 != . | F5M2 != . | F5M3 != .) & n == 3
replace med = 1 if (M3M1 != . | M3M2 != . | M3M3 != .) & n == 4
replace med = 1 if (M5M1 != . | M5M2 != . | M5M3 != .) & n == 5
replace med = 1 if (M6M1 != . | M6M2 != . | M6M3 != .) & n == 6

tab med, mi

gen dark = 0
replace dark = 1 if (F1D1 != . | F1D2 != . | F1D3 != .) & n == 1
replace dark = 1 if (F3D1 != . | F3D2 != . | F3D3 != .) & n == 2
replace dark = 1 if (F5D1 != . | F5D2 != . | F5D3 != .) & n == 3 
replace dark = 1 if (M3D1 != . | M3D2 != . | M3D3 != .) & n == 4
replace dark = 1 if (M5D1 != . | M5D2 != . | M5D3 != .) & n == 5
replace dark = 1 if (M6D1 != . | M6D2 != . | M6D3 != .) & n == 6

tab dark, mi

bigtab light med dark

list q1 F1L1 F1M1 F1D1 F3L1 F3M1 F3D1 light dark med n in 1/300

gen sc2 = 6
replace sc2 = 0 if light == 1
replace sc2 = 1 if med == 1
replace sc2 = 2 if dark == 1
replace sc2 = . if sc2 == 6
label define sc2 0 "Light" 1 "Medium" 2 "Dark"
label values sc2 sc2
tab sc2 light, mi
tab sc2 med, mi
tab sc2 dark, mi


gen q1r = 6-q1 
gen q2r = 6-q2
gen q3r = 6-q3
tab q1r q1, mi
tab q2r q2, mi
tab q3r q3, mi


recode n (1=0) (2=1) (3=2) (4=3) (5=4) (6=5), gen(newn)
gen wn = .
replace wn = 0 if n == 1
replace wn = 1 if n == 2
replace wn = 2 if n == 3

gen mn = .
replace mn = 0 if n == 4
replace mn = 1 if n == 5
replace mn = 2 if n == 6

tab wn newn, mi
tab mn newn, mi

tab sc2, generate(sc2)
tab newn, generate(newnd)
tab mn, generate(mnd)
tab wn, generate(wnd)



tab gsimple, generate(gsimpled) 
tab ceduc, generate(ceducd)
tab nreli, generate(nrelid)
tab cpeduc, generate(cpeducd)
tab nregion, generat(nregiond)
tab nbatch, generate(nbatchd)


//dating
meologit q1r sc2##dateb i.newn || case_id:, vce(cluster case_id) 
est sto b1
meologit q2r sc2##dateb i.newn || case_id:, vce(cluster case_id) 
est sto b2
meologit q3r sc2##dateb i.newn || case_id:, vce(cluster case_id)
est sto b3

meologit q1r ib1.sc2##dateb i.newn || case_id:, vce(cluster case_id) 
est sto b4
meologit q2r ib1.sc2##dateb i.newn || case_id:, vce(cluster case_id) 
est sto b5
meologit q3r ib1.sc2##dateb i.newn || case_id:, vce(cluster case_id)
est sto b6


meologit q1r sc2##dateb i.wn || case_id:, vce(cluster case_id) 
est sto b7
meologit q2r sc2##dateb i.wn || case_id:, vce(cluster case_id) 
est sto b8
meologit q3r sc2##dateb i.wn || case_id:, vce(cluster case_id)
est sto b9

meologit q1r ib1.sc2##dateb i.wn || case_id:, vce(cluster case_id) 
est sto b10
meologit q2r ib1.sc2##dateb i.wn || case_id:, vce(cluster case_id) 
est sto b11
meologit q3r ib1.sc2##dateb i.wn || case_id:, vce(cluster case_id)
est sto b12

meologit q1r sc2##dateb i.mn || case_id:, vce(cluster case_id) 
est sto b13
meologit q2r sc2##dateb i.mn || case_id:, vce(cluster case_id) 
est sto b14
meologit q3r sc2##dateb i.mn || case_id:, vce(cluster case_id)
est sto b15

meologit q1r ib1.sc2##dateb i.mn || case_id:, vce(cluster case_id) 
est sto b16
meologit q2r ib1.sc2##dateb i.mn || case_id:, vce(cluster case_id) 
est sto b17
meologit q3r ib1.sc2##dateb i.mn || case_id:, vce(cluster case_id)
est sto b18


esttab b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 b16 b17 b18 ///
using "sceanalysesdatinginter082124.csv", se star(+ 0.1 * 0.05 ** 0.01 *** 0.001) replace

//sexuality
meologit q1r sc2##nstraight i.newn || case_id:, vce(cluster case_id) 
est sto b1
meologit q2r sc2##nstraight i.newn || case_id:, vce(cluster case_id) 
est sto b2
meologit q3r sc2##nstraight i.newn || case_id:, vce(cluster case_id)
est sto b3

meologit q1r ib1.sc2##nstraight i.newn || case_id:, vce(cluster case_id) 
est sto b4
meologit q2r ib1.sc2##nstraight i.newn || case_id:, vce(cluster case_id) 
est sto b5
meologit q3r ib1.sc2##nstraight i.newn || case_id:, vce(cluster case_id)
est sto b6


meologit q1r sc2##nstraight i.wn || case_id:, vce(cluster case_id) 
est sto b7
meologit q2r sc2##nstraight i.wn || case_id:, vce(cluster case_id) 
est sto b8
meologit q3r sc2##nstraight i.wn || case_id:, vce(cluster case_id)
est sto b9

meologit q1r ib1.sc2##nstraight i.wn || case_id:, vce(cluster case_id) 
est sto b10
meologit q2r ib1.sc2##nstraight i.wn || case_id:, vce(cluster case_id) 
est sto b11
meologit q3r ib1.sc2##nstraight i.wn || case_id:, vce(cluster case_id)
est sto b12

meologit q1r sc2##nstraight i.mn || case_id:, vce(cluster case_id) 
est sto b13
meologit q2r sc2##nstraight i.mn || case_id:, vce(cluster case_id) 
est sto b14
meologit q3r sc2##nstraight i.mn || case_id:, vce(cluster case_id)
est sto b15

meologit q1r ib1.sc2##nstraight i.mn || case_id:, vce(cluster case_id) 
est sto b16
meologit q2r ib1.sc2##nstraight i.mn || case_id:, vce(cluster case_id) 
est sto b17
meologit q3r ib1.sc2##nstraight i.mn || case_id:, vce(cluster case_id)
est sto b18


esttab b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 b16 b17 b18 ///
using "sceanalysessexualityinter082124.csv", se star(+ 0.1 * 0.05 ** 0.01 *** 0.001) replace

log close
clear
